From: Eli Zaretskii Date: Thu, 23 May 2024 09:51:19 +0000 (+0300) Subject: Fix uncompressing a .tar.gz archive whose files have no leading dir X-Git-Tag: archive/raspbian/1%30.1+1-3+rpi1^2~14^2~18^2~1390 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=f75fec5cacce47c9714f10592d75c8fb9c63999d;p=emacs.git Fix uncompressing a .tar.gz archive whose files have no leading dir * lisp/dired-aux.el (dired-compress): Handle the case when NEW-FILE is not produced in the current directory by uncompressing a compressed file. (Bug#47058) --- diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el index 22c6881ae35..d1d5ed9b144 100644 --- a/lisp/dired-aux.el +++ b/lisp/dired-aux.el @@ -1522,14 +1522,23 @@ A FMT of \"\" will suppress the messaging." ;; Remove any preexisting entry for the name NEW-FILE. (ignore-errors (dired-remove-entry new-file)) (goto-char start) - ;; Now replace the current line with an entry for NEW-FILE. - ;; But don't remove the current line if either FROM-FILE or - ;; NEW-FILE is a directory, because compressing/uncompressing - ;; directories doesn't remove the original. - (if (or (file-directory-p from-file) - (file-directory-p new-file)) - (dired-add-entry new-file nil t) - (dired-update-file-line new-file)) + ;; Now replace the current line with an entry for NEW-FILE, + ;; if it exists. But don't remove the current line if + ;; either FROM-FILE or NEW-FILE is a directory, because + ;; compressing/uncompressing directories doesn't remove the + ;; original. If NEW-FILE doesn't exist, assume that we are + ;; out of sync with the current directory, and revert it. + ;; This can happen, for example, when unpacking a .tar.gz + ;; archive which adds files to the current directory (as + ;; opposed to adding them to a directory whose name is + ;; NEW-FILE). + (if (file-exists-p new-file) + (if (or (file-directory-p from-file) + (file-directory-p new-file)) + (dired-add-entry new-file nil t) + (dired-update-file-line new-file)) + (dired-fun-in-all-buffers (dired-current-directory) + nil #'revert-buffer)) nil) (dired-log (concat "Failed to (un)compress " from-file)) from-file)))